﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SendRemandSms.aspx.cs" Inherits="JKF.Web.SMS.Remind.SendRemandSms" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <%= RegScript("~/js/jquery.1.5.js")%>
    <%=RegScript("~/js/Common.js")%>
    <%=RegScript("~/js/jquery.json.js")%>
    <%=RegScript("~/js/jquery.nhis.js")%>
    <%=RegScript("~/js/jquery.rchis.js")%>
    <%=RegScript("~/js/jquery.blockUI.js")%>
    <%=RegScript("~/js/jquery.validate.js")%>
    <%=RegScript("~/js/DatePicker/WdatePicker.js")%>
    <%=RegStyle("~/js/suggest/jquery.suggest.css")%>
    <%=this.RegStyle("~/App_Themes/Theme2/Include.css")%>
    <script type="text/javascript">
        var account=<%=CurrentAccount%>;
        var appPath = "<%=AppPath %>";
        var tmpl = new DTemplate();
        var areaHandler = appPath + '/do/Dic/Dic_Area.do';
        var handler=appPath+"/do/SMS/SmsModule.do";
        var customerHandler=appPath+"/do/Customer/Customer.do";
        var dtReg = /^\d{4}(\/|-)([1][0-2]|[1-9]|0[1-9])(\/|-)([1-2][0-9]|3[0-1]|[1-9]|0[1-9])( (0?[0-9]|1[0-9]|2[0-4])(:([0-5][0-9])){1,2})?$/;
        var mobiles="<%=MobileNums%>";
        var mxChar = 0;
        $(function() {
            BindAccInfo();
            RegisterHandler();
        });

        function RegisterHandler() {
            $("#btnSave").click(SaveTask);
            $("#SMS_TEMPLATE").change(function (){
                var vl=$.trim($(this).find("option[value='"+$(this).val()+"']").attr("cont"));
                if(vl.length>0){$("#CONTENT").val($("#CONTENT").val()+vl);}
                $("#CONTENT").change();
            });
            $("#wordNumLeft").text(250-mxChar);
            $("#CONTENT").keyup(function() {
                $("#wordNum").text($("#CONTENT").val().length);
                $("#wordNumLeft").text(250-mxChar-$("#CONTENT").val().length);
            }).change(function() {$(this).keyup();}).attr("maxlength",250-mxChar);

            alxVr.push({
                id:"MOBILE_NUMS",
                rule:function (cn){
                    if($("#SCOPEPson").attr("checked")){
                        var vl=$.trim(cn.val());
                        if(vl.length==0){
                            this.msg="请输入手机号.";
                            return false;
                        }
                    }
                    return true;
                }
            });
            alxVr.push({
                id:"CONTENT",
                rule:function (cn){
                    var vl=$.trim(cn.val());
                    var sign = $.trim($("#signature").text());
                    if(vl.length==0){
                        this.msg="请选输入短信内容.";
                        return false;
                    }else if (vl.length+sign.length > 250) {
                        this.msg = "短信内容加签名的长度应在250个字符之内.";
                        return false;
                    }
                    return true;
                }
            });
        }

        function BindAccInfo() {
            $("#MOBILE_NUMS").val(mobiles.replace("，",","));
            if (!account) {
                $("input,select,textarea").attr("disabled","disabled");
                $("#NoAccountMsg").text("提示：未开通短信发送功能，无法使用，如要开通请联系管理员.").css("height","auto").css("color","#FF0000");
                return;
            }
            $("#curInfo").html("可发送短信<span class=\"f12red\">"+account.NUM_LEFT+"</span>条,已经发送短信<span class=\"f12red\">"+account.NUM_SENDED+"</span>条");
            $("#signature").text(account.SIGNATURE);
            mxChar = $.trim($.FxNull(account.SIGNATURE), "").length;
        }

        function SaveTask() {
            var obj = {
                ScopeCondition: $("#SCOPEPson").attr("checked"),
                ConditionKey: $.trim($("#CONDITION_KEY").val()),
                MobileNums:[],
                Content: $.trim($("#CONTENT").val()),
                Date: $.trim($("#Date").val()),
                Day: $("#Day").val(),
                Week: $("#Week").val(),
                Hour: $("#Hour").val(),
                Minute: $("#Minute").val(),
                SendNow: $("#SendNow").attr("checked"),
                ByTimeStyle:$("#SendByTime").attr("checked")?$("#ByTimeStyle").val():""
            };
            obj.MobileNums=$.trim($("#MOBILE_NUMS").val()).replace("；",";").split(";");
            $.post(handler,{ActionName:"SmsTaskAdd",taskObj:$.toJSON(obj)},function (rslt){
                if(rslt.Success){
                    alert("添加成功.");
                    return;
                }
                alert(rslt.Message);
            },"json");

        }
    </script>
</head>
<body style="height: auto;">
    <form id="form1" runat="server">
        <div class="pop_logging_body">
            <table class="common_table_noborde" width="100%">
                <tr>
                    <td id="NoAccountMsg" style="height: 0px;" colspan="2"></td>
                </tr>
                <tr>
                    <td width="19%" align="right">当前账户信息：
                    </td>
                    <td id="curInfo"></td>
                </tr>
                <tr>
                    <td align="right">签名：
                    </td>
                    <td id="signature"></td>
                </tr>
                <tr>
                    <td align="right" valign="top">手机号：
                    </td>
                    <td>
                        <textarea rows="4" cols="40" id="MOBILE_NUMS" class="cellphone"><%=MobileNums %></textarea></td>
                </tr>
                <tr>
                    <td align="right">短信模版：
                    </td>
                    <td>
                        <select id="SMS_TEMPLATE">
                            <option>请选择</option>
                            <%=SmsTemplates%>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="top">
                        <span class="f12red">*</span>短信内容：
                    </td>
                    <td>
                        <textarea rows="4" cols="40" id="CONTENT" maxlength="250"></textarea>
                        <div>当前已输入<span id="wordNum" class="f12red">0</span>个字符,还可输入<span id="wordNumLeft" class="f12red">0</span>个字符.(短信总长度不得超过250个字，超过65个字符将会被拆分成多条发送.)</div>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="" id="btnSave" class="common_btn_save" />
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
